class MinStack {
public:
    MinStack() {
        
    }
    
    void push(int val) {
        if(minS.empty()||minS.top()>=val)
            minS.push(val);
        S.push(val);
    }
    
    void pop() {
        if(minS.top()==S.top())
            minS.pop();
        S.pop();
    }
    
    int top() {
        return S.top();
    }
    
    int getMin() {
        return minS.top();
    }
    stack<int> S;
    stack<int>minS;
};

/**
 * Your MinStack object will be instantiated and called as such:
 * MinStack* obj = new MinStack();
 * obj->push(val);
 * obj->pop();
 * int param_3 = obj->top();
 * int param_4 = obj->getMin();
 */
